\c fivedash;
DROP SCHEMA system CASCADE;
CREATE SCHEMA system;

CREATE TABLE system.company (
    id SERIAL PRIMARY KEY,
    name VARCHAR(40) NOT NULL,
    db_ip VARCHAR(40) NOT NULL,	
    db_name VARCHAR(40) NOT NULL,
    db_user VARCHAR(40) NOT NULL,
    db_passwd BYTEA NOT NULL,
    top_id INT NOT NULL DEFAULT(0),
    logo_url VARCHAR(50)
);

CREATE TABLE system.user(
	id SERIAL PRIMARY KEY,
	name VARCHAR(40) UNIQUE NOT NULL,
	passwd VARCHAR(100) NOT NULL,
	skin VARCHAR(20) DEFAULT 'metal',
	is_active BOOLEAN DEFAULT TRUE,
	role_id int[]
);

CREATE TABLE system.group(
	id SERIAL PRIMARY KEY,
	name VARCHAR(40) NOT NULL	--group name (admin, sales, marketing, finance, etc)
);

CREATE TABLE system.role(
	id SERIAL PRIMARY KEY,
	name VARCHAR(40) NOT NULL	--role name (== portal name)
);

CREATE TABLE system.affiliation(
	user_id INT,
	company_id INT,
	group_id INT,
	PRIMARY KEY (user_id, company_id, group_id)
);

CREATE TABLE system.grant(
		group_id INT,
		role_id INT,
		PRIMARY KEY (group_id, role_id)
);

CREATE TABLE system.iso_country_code(
	code VARCHAR(2) PRIMARY KEY,
	name VARCHAR(60) NOT NULL,
	alias VARCHAR(30)[]
);

-----------------------------------------init-----------------------------------------
CREATE OR REPLACE FUNCTION system.drop_company() RETURNS TRIGGER AS $$
    BEGIN		
        DELETE FROM system.affiliation WHERE company_id=OLD.id;
        RETURN NEW;
    END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER drop_company after DELETE ON system.company FOR EACH ROW EXECUTE PROCEDURE system.drop_company();

CREATE OR REPLACE FUNCTION system.drop_group() RETURNS TRIGGER AS $$
    BEGIN		
        DELETE FROM system.affiliation WHERE group_id=OLD.id;
        RETURN NEW;
    END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER drop_group after DELETE ON system.group FOR EACH ROW EXECUTE PROCEDURE system.drop_group();

INSERT INTO system.user VALUES (DEFAULT,'{{username}}','{{password}}','metal');

INSERT INTO system.role VALUES (DEFAULT,'operations');
INSERT INTO system.role VALUES (DEFAULT,'finance');
INSERT INTO system.role VALUES (DEFAULT,'crm');
INSERT INTO system.role VALUES (DEFAULT,'admin');
INSERT INTO system.role VALUES (DEFAULT,'report');
INSERT INTO system.role VALUES (DEFAULT,'extras');

INSERT INTO system.group VALUES (DEFAULT,'root');
INSERT INTO system.group VALUES (DEFAULT,'company admin');
INSERT INTO system.group VALUES (DEFAULT,'finance');
INSERT INTO system.group VALUES (DEFAULT,'marketing');
INSERT INTO system.group VALUES (DEFAULT,'sales');

INSERT INTO system.grant VALUES (1, 1);
INSERT INTO system.grant VALUES (1, 2);
INSERT INTO system.grant VALUES (1, 3);
INSERT INTO system.grant VALUES (1, 4);
INSERT INTO system.grant VALUES (1, 5);

INSERT INTO system.grant VALUES (2, 1);
INSERT INTO system.grant VALUES (2, 2);
INSERT INTO system.grant VALUES (2, 3);
INSERT INTO system.grant VALUES (2, 4);
INSERT INTO system.grant VALUES (2, 5);

INSERT INTO system.grant VALUES (3, 2);
INSERT INTO system.grant VALUES (3, 4);
INSERT INTO system.grant VALUES (3, 5);

INSERT INTO system.grant VALUES (4, 3);

INSERT INTO system.grant VALUES (5, 1);
INSERT INTO system.grant VALUES (5, 3);

---------country codes------------
INSERT INTO system.iso_country_code VALUES ('AF', 'AFGHANISTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('AX', 'ALAND ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('AL', 'ALBANIA', NULL);
INSERT INTO system.iso_country_code VALUES ('DZ', 'ALGERIA', NULL);
INSERT INTO system.iso_country_code VALUES ('AS', 'AMERICAN SAMOA', NULL);
INSERT INTO system.iso_country_code VALUES ('AD', 'ANDORRA', NULL);
INSERT INTO system.iso_country_code VALUES ('AO', 'ANGOLA', NULL);
INSERT INTO system.iso_country_code VALUES ('AI', 'ANGUILLA', NULL);
INSERT INTO system.iso_country_code VALUES ('AQ', 'ANTARCTICA', NULL);
INSERT INTO system.iso_country_code VALUES ('AG', 'ANTIGUA AND BARBUDA', NULL);
INSERT INTO system.iso_country_code VALUES ('AR', 'ARGENTINA', NULL);
INSERT INTO system.iso_country_code VALUES ('AM', 'ARMENIA', NULL);
INSERT INTO system.iso_country_code VALUES ('AW', 'ARUBA', NULL);
INSERT INTO system.iso_country_code VALUES ('AU', 'AUSTRALIA', NULL);
INSERT INTO system.iso_country_code VALUES ('AT', 'AUSTRIA', NULL);
INSERT INTO system.iso_country_code VALUES ('AZ', 'AZERBAIJAN', NULL);
INSERT INTO system.iso_country_code VALUES ('BS', 'BAHAMAS', NULL);
INSERT INTO system.iso_country_code VALUES ('BH', 'BAHRAIN', NULL);
INSERT INTO system.iso_country_code VALUES ('BD', 'BANGLADESH', NULL);
INSERT INTO system.iso_country_code VALUES ('BB', 'BARBADOS', NULL);
INSERT INTO system.iso_country_code VALUES ('BY', 'BELARUS', NULL);
INSERT INTO system.iso_country_code VALUES ('BE', 'BELGIUM', NULL);
INSERT INTO system.iso_country_code VALUES ('BZ', 'BELIZE', NULL);
INSERT INTO system.iso_country_code VALUES ('BJ', 'BENIN', NULL);
INSERT INTO system.iso_country_code VALUES ('BM', 'BERMUDA', NULL);
INSERT INTO system.iso_country_code VALUES ('BT', 'BHUTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('BO', 'BOLIVIA', NULL);
INSERT INTO system.iso_country_code VALUES ('BA', 'BOSNIA AND HERZEGOVINA', NULL);
INSERT INTO system.iso_country_code VALUES ('BW', 'BOTSWANA', NULL);
INSERT INTO system.iso_country_code VALUES ('BV', 'BOUVET ISLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('BR', 'BRAZIL', NULL);
INSERT INTO system.iso_country_code VALUES ('IO', 'BRITISH INDIAN OCEAN TERRITORY', NULL);
INSERT INTO system.iso_country_code VALUES ('BN', 'BRUNEI DARUSSALAM', NULL);
INSERT INTO system.iso_country_code VALUES ('BG', 'BULGARIA', NULL);
INSERT INTO system.iso_country_code VALUES ('BF', 'BURKINA FASO', NULL);
INSERT INTO system.iso_country_code VALUES ('BI', 'BURUNDI', NULL);
INSERT INTO system.iso_country_code VALUES ('KH', 'CAMBODIA', NULL);
INSERT INTO system.iso_country_code VALUES ('CM', 'CAMEROON', NULL);
INSERT INTO system.iso_country_code VALUES ('CA', 'CANADA', NULL);
INSERT INTO system.iso_country_code VALUES ('CV', 'CAPE VERDE', NULL);
INSERT INTO system.iso_country_code VALUES ('KY', 'CAYMAN ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('CF', 'CENTRAL AFRICAN REPUBLIC', NULL);
INSERT INTO system.iso_country_code VALUES ('TD', 'CHAD', NULL);
INSERT INTO system.iso_country_code VALUES ('CL', 'CHILE', NULL);
INSERT INTO system.iso_country_code VALUES ('CN', 'CHINA', NULL);
INSERT INTO system.iso_country_code VALUES ('CX', 'CHRISTMAS ISLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('CC', 'COCOS (KEELING) ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('CO', 'COLOMBIA', NULL);
INSERT INTO system.iso_country_code VALUES ('KM', 'COMOROS', NULL);
INSERT INTO system.iso_country_code VALUES ('CG', 'CONGO', NULL);
INSERT INTO system.iso_country_code VALUES ('CD', 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', '{"DR CONGO"}');
INSERT INTO system.iso_country_code VALUES ('CK', 'COOK ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('CR', 'COSTA RICA', NULL);
INSERT INTO system.iso_country_code VALUES ('CI', 'COTE D''IVOIRE', NULL);
INSERT INTO system.iso_country_code VALUES ('HR', 'CROATIA', NULL);
INSERT INTO system.iso_country_code VALUES ('CU', 'CUBA', NULL);
INSERT INTO system.iso_country_code VALUES ('CY', 'CYPRUS', NULL);
INSERT INTO system.iso_country_code VALUES ('CZ', 'CZECH REPUBLIC', NULL);
INSERT INTO system.iso_country_code VALUES ('DK', 'DENMARK', NULL);
INSERT INTO system.iso_country_code VALUES ('DJ', 'DJIBOUTI', NULL);
INSERT INTO system.iso_country_code VALUES ('DM', 'DOMINICA', NULL);
INSERT INTO system.iso_country_code VALUES ('DO', 'DOMINICAN REPUBLIC', NULL);
INSERT INTO system.iso_country_code VALUES ('EC', 'ECUADOR', NULL);
INSERT INTO system.iso_country_code VALUES ('EG', 'EGYPT', NULL);
INSERT INTO system.iso_country_code VALUES ('SV', 'EL SALVADOR', NULL);
INSERT INTO system.iso_country_code VALUES ('GQ', 'EQUATORIAL GUINEA', NULL);
INSERT INTO system.iso_country_code VALUES ('ER', 'ERITREA', NULL);
INSERT INTO system.iso_country_code VALUES ('EE', 'ESTONIA', NULL);
INSERT INTO system.iso_country_code VALUES ('ET', 'ETHIOPIA', NULL);
INSERT INTO system.iso_country_code VALUES ('FK', 'FALKLAND ISLANDS (MALVINAS)', NULL);
INSERT INTO system.iso_country_code VALUES ('FO', 'FAROE ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('FJ', 'FIJI', NULL);
INSERT INTO system.iso_country_code VALUES ('FI', 'FINLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('FR', 'FRANCE', NULL);
INSERT INTO system.iso_country_code VALUES ('GF', 'FRENCH GUIANA', NULL);
INSERT INTO system.iso_country_code VALUES ('PF', 'FRENCH POLYNESIA', NULL);
INSERT INTO system.iso_country_code VALUES ('TF', 'FRENCH SOUTHERN TERRITORIES', NULL);
INSERT INTO system.iso_country_code VALUES ('GA', 'GABON', NULL);
INSERT INTO system.iso_country_code VALUES ('GM', 'GAMBIA', NULL);
INSERT INTO system.iso_country_code VALUES ('GE', 'GEORGIA', NULL);
INSERT INTO system.iso_country_code VALUES ('DE', 'GERMANY', NULL);
INSERT INTO system.iso_country_code VALUES ('GH', 'GHANA', NULL);
INSERT INTO system.iso_country_code VALUES ('GI', 'GIBRALTAR', NULL);
INSERT INTO system.iso_country_code VALUES ('GR', 'GREECE', NULL);
INSERT INTO system.iso_country_code VALUES ('GL', 'GREENLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('GD', 'GRENADA', NULL);
INSERT INTO system.iso_country_code VALUES ('GP', 'GUADELOUPE', NULL);
INSERT INTO system.iso_country_code VALUES ('GU', 'GUAM', NULL);
INSERT INTO system.iso_country_code VALUES ('GT', 'GUATEMALA', NULL);
INSERT INTO system.iso_country_code VALUES ('GG', 'GUERNSEY', NULL);
INSERT INTO system.iso_country_code VALUES ('GN', 'GUINEA', NULL);
INSERT INTO system.iso_country_code VALUES ('GW', 'GUINEA-BISSAU', NULL);
INSERT INTO system.iso_country_code VALUES ('GY', 'GUYANA', NULL);
INSERT INTO system.iso_country_code VALUES ('HT', 'HAITI', NULL);
INSERT INTO system.iso_country_code VALUES ('HM', 'HEARD ISLAND AND MCDONALD ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('VA', 'HOLY SEE (VATICAN CITY STATE)', NULL);
INSERT INTO system.iso_country_code VALUES ('HN', 'HONDURAS', NULL);
INSERT INTO system.iso_country_code VALUES ('HK', 'HONG KONG', NULL);
INSERT INTO system.iso_country_code VALUES ('HU', 'HUNGARY', NULL);
INSERT INTO system.iso_country_code VALUES ('IS', 'ICELAND', NULL);
INSERT INTO system.iso_country_code VALUES ('IN', 'INDIA', NULL);
INSERT INTO system.iso_country_code VALUES ('ID', 'INDONESIA', NULL);
INSERT INTO system.iso_country_code VALUES ('IR', 'IRAN, ISLAMIC REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('IQ', 'IRAQ', NULL);
INSERT INTO system.iso_country_code VALUES ('IE', 'IRELAND', NULL);
INSERT INTO system.iso_country_code VALUES ('IM', 'ISLE OF MAN', NULL);
INSERT INTO system.iso_country_code VALUES ('IL', 'ISRAEL', NULL);
INSERT INTO system.iso_country_code VALUES ('IT', 'ITALY', NULL);
INSERT INTO system.iso_country_code VALUES ('JM', 'JAMAICA', NULL);
INSERT INTO system.iso_country_code VALUES ('JP', 'JAPAN', NULL);
INSERT INTO system.iso_country_code VALUES ('JE', 'JERSEY', NULL);
INSERT INTO system.iso_country_code VALUES ('JO', 'JORDAN', NULL);
INSERT INTO system.iso_country_code VALUES ('KZ', 'KAZAKHSTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('KE', 'KENYA', NULL);
INSERT INTO system.iso_country_code VALUES ('KI', 'KIRIBATI', NULL);
INSERT INTO system.iso_country_code VALUES ('KP', 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('KR', 'KOREA, REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('KW', 'KUWAIT', NULL);
INSERT INTO system.iso_country_code VALUES ('KG', 'KYRGYZSTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('LA', 'LAO PEOPLE''S DEMOCRATIC REPUBLIC', NULL);
INSERT INTO system.iso_country_code VALUES ('LV', 'LATVIA', NULL);
INSERT INTO system.iso_country_code VALUES ('LB', 'LEBANON', NULL);
INSERT INTO system.iso_country_code VALUES ('LS', 'LESOTHO', NULL);
INSERT INTO system.iso_country_code VALUES ('LR', 'LIBERIA', NULL);
INSERT INTO system.iso_country_code VALUES ('LY', 'LIBYAN ARAB JAMAHIRIYA', NULL);
INSERT INTO system.iso_country_code VALUES ('LI', 'LIECHTENSTEIN', NULL);
INSERT INTO system.iso_country_code VALUES ('LT', 'LITHUANIA', NULL);
INSERT INTO system.iso_country_code VALUES ('LU', 'LUXEMBOURG', NULL);
INSERT INTO system.iso_country_code VALUES ('MO', 'MACAO', NULL);
INSERT INTO system.iso_country_code VALUES ('MK', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('MG', 'MADAGASCAR', NULL);
INSERT INTO system.iso_country_code VALUES ('MW', 'MALAWI', NULL);
INSERT INTO system.iso_country_code VALUES ('MY', 'MALAYSIA', NULL);
INSERT INTO system.iso_country_code VALUES ('MV', 'MALDIVES', NULL);
INSERT INTO system.iso_country_code VALUES ('ML', 'MALI', NULL);
INSERT INTO system.iso_country_code VALUES ('MT', 'MALTA', NULL);
INSERT INTO system.iso_country_code VALUES ('MH', 'MARSHALL ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('MQ', 'MARTINIQUE', NULL);
INSERT INTO system.iso_country_code VALUES ('MR', 'MAURITANIA', NULL);
INSERT INTO system.iso_country_code VALUES ('MU', 'MAURITIUS', NULL);
INSERT INTO system.iso_country_code VALUES ('YT', 'MAYOTTE', NULL);
INSERT INTO system.iso_country_code VALUES ('MX', 'MEXICO', NULL);
INSERT INTO system.iso_country_code VALUES ('FM', 'MICRONESIA, FEDERATED STATES OF', NULL);
INSERT INTO system.iso_country_code VALUES ('MD', 'MOLDOVA, REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('MC', 'MONACO', NULL);
INSERT INTO system.iso_country_code VALUES ('MN', 'MONGOLIA', NULL);
INSERT INTO system.iso_country_code VALUES ('ME', 'MONTENEGRO', NULL);
INSERT INTO system.iso_country_code VALUES ('MS', 'MONTSERRAT', NULL);
INSERT INTO system.iso_country_code VALUES ('MA', 'MOROCCO', NULL);
INSERT INTO system.iso_country_code VALUES ('MZ', 'MOZAMBIQUE', NULL);
INSERT INTO system.iso_country_code VALUES ('MM', 'MYANMAR', NULL);
INSERT INTO system.iso_country_code VALUES ('NA', 'NAMIBIA', NULL);
INSERT INTO system.iso_country_code VALUES ('NR', 'NAURU', NULL);
INSERT INTO system.iso_country_code VALUES ('NP', 'NEPAL', NULL);
INSERT INTO system.iso_country_code VALUES ('NL', 'NETHERLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('AN', 'NETHERLANDS ANTILLES', NULL);
INSERT INTO system.iso_country_code VALUES ('NC', 'NEW CALEDONIA', NULL);
INSERT INTO system.iso_country_code VALUES ('NZ', 'NEW ZEALAND', '{"NZ"}');
INSERT INTO system.iso_country_code VALUES ('NI', 'NICARAGUA', NULL);
INSERT INTO system.iso_country_code VALUES ('NE', 'NIGER', NULL);
INSERT INTO system.iso_country_code VALUES ('NG', 'NIGERIA', NULL);
INSERT INTO system.iso_country_code VALUES ('NU', 'NIUE', NULL);
INSERT INTO system.iso_country_code VALUES ('NF', 'NORFOLK ISLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('MP', 'NORTHERN MARIANA ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('NO', 'NORWAY', NULL);
INSERT INTO system.iso_country_code VALUES ('OM', 'OMAN', NULL);
INSERT INTO system.iso_country_code VALUES ('PK', 'PAKISTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('PW', 'PALAU', NULL);
INSERT INTO system.iso_country_code VALUES ('PS', 'PALESTINIAN TERRITORY, OCCUPIED', NULL);
INSERT INTO system.iso_country_code VALUES ('PA', 'PANAMA', NULL);
INSERT INTO system.iso_country_code VALUES ('PG', 'PAPUA NEW GUINEA', NULL);
INSERT INTO system.iso_country_code VALUES ('PY', 'PARAGUAY', NULL);
INSERT INTO system.iso_country_code VALUES ('PE', 'PERU', NULL);
INSERT INTO system.iso_country_code VALUES ('PH', 'PHILIPPINES', NULL);
INSERT INTO system.iso_country_code VALUES ('PN', 'PITCAIRN', NULL);
INSERT INTO system.iso_country_code VALUES ('PL', 'POLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('PT', 'PORTUGAL', NULL);
INSERT INTO system.iso_country_code VALUES ('PR', 'PUERTO RICO', NULL);
INSERT INTO system.iso_country_code VALUES ('QA', 'QATAR', NULL);
INSERT INTO system.iso_country_code VALUES ('RE', 'REUNION', NULL);
INSERT INTO system.iso_country_code VALUES ('RO', 'ROMANIA', NULL);
INSERT INTO system.iso_country_code VALUES ('RU', 'RUSSIAN FEDERATION', NULL);
INSERT INTO system.iso_country_code VALUES ('RW', 'RWANDA', NULL);
INSERT INTO system.iso_country_code VALUES ('BL', 'SAINT BARTHELEMY', NULL);
INSERT INTO system.iso_country_code VALUES ('SH', 'SAINT HELENA', NULL);
INSERT INTO system.iso_country_code VALUES ('KN', 'SAINT KITTS AND NEVIS', NULL);
INSERT INTO system.iso_country_code VALUES ('LC', 'SAINT LUCIA', NULL);
INSERT INTO system.iso_country_code VALUES ('MF', 'SAINT MARTIN', NULL);
INSERT INTO system.iso_country_code VALUES ('PM', 'SAINT PIERRE AND MIQUELON', NULL);
INSERT INTO system.iso_country_code VALUES ('VC', 'SAINT VINCENT AND THE GRENADINES', NULL);
INSERT INTO system.iso_country_code VALUES ('WS', 'SAMOA', NULL);
INSERT INTO system.iso_country_code VALUES ('SM', 'SAN MARINO', NULL);
INSERT INTO system.iso_country_code VALUES ('ST', 'SAO TOME AND PRINCIPE', NULL);
INSERT INTO system.iso_country_code VALUES ('SA', 'SAUDI ARABIA', NULL);
INSERT INTO system.iso_country_code VALUES ('SN', 'SENEGAL', NULL);
INSERT INTO system.iso_country_code VALUES ('RS', 'SERBIA', NULL);
INSERT INTO system.iso_country_code VALUES ('SC', 'SEYCHELLES', NULL);
INSERT INTO system.iso_country_code VALUES ('SL', 'SIERRA LEONE', NULL);
INSERT INTO system.iso_country_code VALUES ('SG', 'SINGAPORE', NULL);
INSERT INTO system.iso_country_code VALUES ('SK', 'SLOVAKIA', NULL);
INSERT INTO system.iso_country_code VALUES ('SI', 'SLOVENIA', NULL);
INSERT INTO system.iso_country_code VALUES ('SB', 'SOLOMON ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('SO', 'SOMALIA', NULL);
INSERT INTO system.iso_country_code VALUES ('ZA', 'SOUTH AFRICA', NULL);
INSERT INTO system.iso_country_code VALUES ('GS', 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('ES', 'SPAIN', NULL);
INSERT INTO system.iso_country_code VALUES ('LK', 'SRI LANKA', NULL);
INSERT INTO system.iso_country_code VALUES ('SD', 'SUDAN', NULL);
INSERT INTO system.iso_country_code VALUES ('SR', 'SURINAME', NULL);
INSERT INTO system.iso_country_code VALUES ('SJ', 'SVALBARD AND JAN MAYEN', NULL);
INSERT INTO system.iso_country_code VALUES ('SZ', 'SWAZILAND', NULL);
INSERT INTO system.iso_country_code VALUES ('SE', 'SWEDEN', NULL);
INSERT INTO system.iso_country_code VALUES ('CH', 'SWITZERLAND', NULL);
INSERT INTO system.iso_country_code VALUES ('SY', 'SYRIAN ARAB REPUBLIC', NULL);
INSERT INTO system.iso_country_code VALUES ('TW', 'TAIWAN, PROVINCE OF CHINA', NULL);
INSERT INTO system.iso_country_code VALUES ('TJ', 'TAJIKISTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('TZ', 'TANZANIA, UNITED REPUBLIC OF', NULL);
INSERT INTO system.iso_country_code VALUES ('TH', 'THAILAND', NULL);
INSERT INTO system.iso_country_code VALUES ('TL', 'TIMOR-LESTE', NULL);
INSERT INTO system.iso_country_code VALUES ('TG', 'TOGO', NULL);
INSERT INTO system.iso_country_code VALUES ('TK', 'TOKELAU', NULL);
INSERT INTO system.iso_country_code VALUES ('TO', 'TONGA', NULL);
INSERT INTO system.iso_country_code VALUES ('TT', 'TRINIDAD AND TOBAGO', NULL);
INSERT INTO system.iso_country_code VALUES ('TN', 'TUNISIA', NULL);
INSERT INTO system.iso_country_code VALUES ('TR', 'TURKEY', NULL);
INSERT INTO system.iso_country_code VALUES ('TM', 'TURKMENISTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('TC', 'TURKS AND CAICOS ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('TV', 'TUVALU', NULL);
INSERT INTO system.iso_country_code VALUES ('UG', 'UGANDA', NULL);
INSERT INTO system.iso_country_code VALUES ('UA', 'UKRAINE', NULL);
INSERT INTO system.iso_country_code VALUES ('AE', 'UNITED ARAB EMIRATES', NULL);
INSERT INTO system.iso_country_code VALUES ('GB', 'UNITED KINGDOM', '{"UK","GREAT BRITAIN"}');
INSERT INTO system.iso_country_code VALUES ('US', 'UNITED STATES', '{"USA","U.S.A.","UNITED STATES OF AMERICA"}');
INSERT INTO system.iso_country_code VALUES ('UM', 'UNITED STATES MINOR OUTLYING ISLANDS', NULL);
INSERT INTO system.iso_country_code VALUES ('UY', 'URUGUAY', NULL);
INSERT INTO system.iso_country_code VALUES ('UZ', 'UZBEKISTAN', NULL);
INSERT INTO system.iso_country_code VALUES ('VU', 'VANUATU', NULL);
INSERT INTO system.iso_country_code VALUES ('VE', 'VENEZUELA', NULL);
INSERT INTO system.iso_country_code VALUES ('VN', 'VIET NAM', '{"VIETNAM"}');
INSERT INTO system.iso_country_code VALUES ('VG', 'VIRGIN ISLANDS, BRITISH', NULL);
INSERT INTO system.iso_country_code VALUES ('VI', 'VIRGIN ISLANDS, U.S.', NULL);
INSERT INTO system.iso_country_code VALUES ('WF', 'WALLIS AND FUTUNA', NULL);
INSERT INTO system.iso_country_code VALUES ('EH', 'WESTERN SAHARA', NULL);
INSERT INTO system.iso_country_code VALUES ('YE', 'YEMEN', NULL);
INSERT INTO system.iso_country_code VALUES ('ZM', 'ZAMBIA', NULL);
INSERT INTO system.iso_country_code VALUES ('ZW', 'ZIMBABWE', NULL);
